﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HienThi;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace DAO
{
    public class BanHangKTVDAO
    {
        public List<BanHangKTVHienThi> LayBangBanHangKTV()
        {
            SqlConnection conn = DataProvider.ConnectDB();
            string sqlStr = "select * from SanPham";
            SqlCommand cmd = new SqlCommand(sqlStr, conn);
            SqlDataReader dr = cmd.ExecuteReader();
            List<BanHangKTVHienThi> kq = new List<BanHangKTVHienThi>();
            int i = 1;
            while (dr.Read())
            {
                BanHangKTVHienThi temp = new BanHangKTVHienThi();
                temp.STT = i;
                temp.MaSP = dr["MaSP"].ToString();
                temp.TenSP = dr["TenSP"].ToString();
                temp.DonGia = float.Parse(dr["DonGia"].ToString());
                temp.SoLuong = 0;
                temp.ThanhTien = 0;
                kq.Add(temp);
                i++;
            }
            return kq;
        }
        public List<ThanhVien> LayBangThanhVien()
        {
            SqlConnection conn = DataProvider.ConnectDB();
            string sqlStr = "select * from ThanhVien";
            SqlCommand cmd = new SqlCommand(sqlStr, conn);
            SqlDataReader dr = cmd.ExecuteReader();
            List<ThanhVien> kq = new List<ThanhVien>();
            while (dr.Read())
            {
                ThanhVien temp = new ThanhVien();
                temp.MaTV = dr["MaTV"].ToString();
                temp.TenTV = dr["TenTV"].ToString();
                temp.NgaySinh = DateTime.Parse(dr["NgaySinh"].ToString());
                temp.DiaChi = dr["DiaChi"].ToString();
                temp.SDT = dr["SDT"].ToString();
                temp.CV = int.Parse(dr["CV"].ToString());
                kq.Add(temp);
            }
            return kq;
        }
    }
}
